import React from 'react';

import './index.less';

import {render} from 'src/hrpub/common/frame';

import {
    base
} from 'nc-lightapp-front';

import BatchAction from '../../actions/batchAdd';

import EntryInfo from './components/EntryInfo';
import SelectMan from './components/SelectMan';
import {COMMON} from "../../main/util";
import FormAction from "./components/EntryInfo/actions";

const {
    NCModal,
    NCStep,
    NCButton
} = base;

const {
    Header,
    Body,
    Footer
} = NCModal;

const {NCSteps} = NCStep;


export default render({
    actions: {
        batchAct: BatchAction,
        formAct: FormAction,
    },
    state: {
        selectAll: false,
        selectRows: null
    }
})(({props, state, action}) => {
    const {
        transfer,
        form,
        search,
        editTable
    } = props;

    return (
        <NCModal
            show={transfer.batchAddShow}
            size="lg"
            onHide={action.batchAct.closeBatchModal}
            className="batch-add-modal"
        >
            <Header
                closeButton={true}
            >
                {transfer.language['gx6008-000057']/** 批量新增 */}
            </Header>
            <Body>
                <div className="batch-add-modal-step-wrapper">
                    <NCSteps
                        current={transfer.batchAddCurrentStep}
                    >
                        <NCStep
                            title={transfer.language['gx6008-000058']/** "选择人员" */}
                        />
                        <NCStep
                            title={transfer.language['gx6008-000087'/** "调配信息" */]}
                        />
                    </NCSteps>
                </div>

                {/*第一步*/}
                <If condition={transfer.batchAddCurrentStep === 0}>
                    <SelectMan 
                        pk_org={transfer.hrorgobj ? transfer.hrorgobj.refpk : ''}
                        transMode={transfer.stapplyMode}
                        search={search}
                        language={transfer.language}
                        editTable={editTable}
                        changePersonRefer={action.batchAct.changePersonRefer}
                        selectedAll={action.batchAct.selectedAll}
                        openBatchAddSearchModal={action.batchAct.openBatchAddSearchModal}
                    />
                {/*第二步*/}
                <Else/>
                    <EntryInfo 
                        form={form}
                        formBeforeEdit={action.formAct.onBeforeEvent}
                        formAfterEdit={action.formAct.onAfterEvent}
                        transfer={transfer}
                    />
                </If>
                <div style={{
                    display: 'none'
                }}>
                    {props.search.NCCreateSearch(COMMON.searchId2, {
                        clickSearchBtn: action.batchAct.toSearchWrapper
                    })}
                </div>
            </Body>
            <Footer>
                <div className="batch-add-modal-footer">
                    <NCButton
                        disabled={transfer.batchAddCurrentStep === 0}
                        onClick={action.batchAct.goToPrevStep}
                    >
                        {transfer.language['gx6008-000062']/** 上一步 */}
                    </NCButton>
                    <NCButton
                        disabled={transfer.batchAddCurrentStep === 1}
                        onClick={action.batchAct.goToNextStep}
                    >
                        {transfer.language['gx6008-000063']/** 下一步 */}
                    </NCButton>
                    <NCButton
                        disabled={transfer.batchAddCurrentStep === 0}
                        onClick={action.batchAct.submitBatchAdd}
                    >
                        {transfer.language['gx6008-000064']/** 完成 */}
                    </NCButton>
                    <NCButton
                        onClick={action.batchAct.closeBatchModal}
                    >
                        {transfer.language['gx6008-000025']/** 取消 */}
                    </NCButton>
                </div>
            </Footer>
        </NCModal>
    );

});